package avicit.cbb.techclass.tabledefine.commtablemanager.action;

import java.io.InputStream;
import java.util.Properties;

import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

/**
 * <p>
 * 金航数码科技有限责任公司
 * </p>
 * <p>
 * 作者：朱锋
 * </p>
 * <p>
 * 邮箱：@avicit.com
 * </p>
 * <p>
 * 创建时间： 2015-4-1 上午11:52:54
 * </p>
 * <p>
 * 类说明：
 * </p>
 * <p>
 * 修改记录：
 * </p>
 */

public class CommTableSysFieldLoader {
	private Properties prop = new Properties();
	/**
	 * 初始化
	 * @throws Exception void
	 * @throws
	 */
	public void init() throws Exception {
		ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
		//加载文件配置
		Resource res = resourceResolver.getResource("classpath:/configuration/tabledeptoruserfield.properties");
		InputStream in = res.getInputStream();
		try {
			if (in != null) {
				prop.load(in);
				in.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 获取字段信息
	 * @return String
	 * @throws
	 */
	public String getFields() {
		if (prop.getProperty("field") != null) {
			return prop.getProperty("field").trim();
		} else {
			return "";
		}
	}
	/**
	 * 获取上传临时文件路径
	 * @return String
	 * @throws
	 */
	public String getPath() {
		if (prop.getProperty("path") != null) {
			return prop.getProperty("path").trim();
		} else {
			return "";
		}
	}
	
	/**
	 * 获取附件类型名称
	 * @return String
	 * @throws
	 */
	public String getAttachmentClassName() throws Exception {
		if (prop.getProperty("attachmentClassName") != null) {
			String attachmentClassName = prop.getProperty("attachmentClassName").trim();
			attachmentClassName = new String(attachmentClassName.getBytes("ISO-8859-1"),"UTF-8");
			return attachmentClassName;
		} else {
			return "";
		}
	}
}
